package com.apestech.framework.xml.condition.node;

import com.apestech.framework.json.JSONObject;
import com.apestech.framework.xml.condition.modul.ConditionStrategy;
import com.apestech.framework.xml.pub.core.ElementUtil;
import com.apestech.framework.xml.pub.core.NodeJson;
import org.dom4j.Element;

import java.util.List;

/**
 * @author hup
 * @create 2019-02-28-14:38
 */
public class NodeConditionStrategy extends ElementUtil {
    private Element node;
    private ConditionStrategy conditionStrategy;

    public NodeConditionStrategy(Element node){
        this.node=node;
    }

    public void getData() throws Exception {
        if(conditionStrategy==null) conditionStrategy=new ConditionStrategy();
        conditionStrategy.setConditionStrategy(getNodeAttr(node).getJSONObject("attrNode"));
        if("IF_TEST".equals(conditionStrategy.getId())){
            System.out.println("");
        }
        List<?> list=node.content();
        int len=list.size();
        for(int i=0; i<len; i++){
            String scalss=list.get(i).getClass().getName();
            if(scalss.equals("org.dom4j.tree.DefaultElement")){
                Element ele=(Element) list.get(i);
                NodeStep nodeStep=new NodeStep(ele, conditionStrategy, null);
                nodeStep.getData();
            }
        }
    }

    public ConditionStrategy getConditionStrategy() {
        return conditionStrategy;
    }
}
